package com.clickhouse_test.app.controller;

import com.clickhouse_test.app.service.ClickhouseLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
public class ClickhouseLogController {

    private final ClickhouseLogService clickhouseLogService;

    @Autowired
    public ClickhouseLogController(ClickhouseLogService clickhouseLogService) {
        this.clickhouseLogService = clickhouseLogService;
    }

    @GetMapping("/getLog_inspection_journal")
    public String getClickhouse(int page, int pageSize){
        //System.out.println(clickhouseLogService.getClickhouse(page, pageSize));
        return clickhouseLogService.getClickhouse(page, pageSize);
    }

    @GetMapping("/getLog_inspection_journal_column")
    public String getLog_inspection_journal_column(String CATALOG_CODE, String INSPECTION_DATE) {
        return clickhouseLogService.getLog_inspection_journal_column(CATALOG_CODE, INSPECTION_DATE);
    }

    @GetMapping("/getLogData_uuid")
    public String getLogData_uuid(int page, int pageSize, String CATALOG_CODE, String INSPECTION_DATE, String ERROR_CODE, String FIELD_NAME){
        return clickhouseLogService.getLogData_uuid(page, pageSize, CATALOG_CODE, INSPECTION_DATE, ERROR_CODE, FIELD_NAME);
    }

    @GetMapping("/debug")
    public String debug(){
        System.out.println("1111");
        return "1111";
    }
}
